'use strict';

/**
 * @ngdoc function
 * @name htmsMobileApp.controller:QiyemainCtrl
 * @description
 * # QiyemainCtrl
 * Controller of the htmsMobileApp
 */
angular.module('htmsMobileApp')
  .controller('QiyemainCtrl', function ($scope,Authentication,CustomHttp) {
    $scope.awesomeThings = [
      'HTML5 Boilerplate',
      'AngularJS',
      'Karma'
    ];
    //企业工作提醒
    CustomHttp.get("/api/entTixing/yinhuanQingkuang/" + Authentication.getUser().depid).success(function (data) {
      $scope.jdjcfxYZG = data[0];
      $scope.jdjcfxZGZ = data[1];
      $scope.jdjcfxWZG = data[2];
      $scope.zcjcfxYZG = data[3];
      $scope.zcjcfxZGZ = data[4];
      $scope.zcjcfxWZG = data[5];
      $scope.yhzdyhYZG = data[6];
      $scope.yhzdyhZGZ = data[7];
      $scope.yhzdyhWZG = data[8];
    });
    //亮灯亮牌
    CustomHttp.get("/api/light/" + Authentication.getUser().depid).success(function (data) {
      $scope.red = 0;
      $scope.green = 0;
      $scope.orange = 0;
      $scope.yellow = 0;
      if(data.length != 0){
        for(var i = 0;i < data.length;i++){
          var obj = data[i];
          switch (obj.zl){
            case 1 :$scope.green++;break;
            case 2:$scope.orange++;break;
            case 3:$scope.red++;break;
            case 4:$scope.yellow++;break;
          }
        }
      }
    });
    //企业基本信息状态与隐患上报状态
    CustomHttp.get("/api/entTixing/isReport/" + Authentication.getUser().depid).success(function (data) {
      $scope.qyjbxxzt = data[0].bdzt;
      switch (data[0].bdzt){
        case 1:$scope.shMsg = "企业基础信息未上报！";break;
        case 2:$scope.shMsg = "企业基础信息待核查！";break;
        case 3:$scope.shMsg = "企业基础信息待审核！";break;
        case 4:$scope.shMsg = "企业基础信息已通过审核！";break;
        case 5:$scope.shMsg = "企业基础信息审核未通过！";break;
        case 6:$scope.shMsg = "企业基础信息审核申请重新指定监管部门！";break;
      }
      $scope.yhsbzt = data[1].isReportThisMon;
    });
    //升降级评级申请
    CustomHttp.get("/api/entBaseInfo/" + Authentication.getUser().depid).success(function (data) {
      $scope.bjMsg = "";
      //企业基本信息没有通过初审不能评级
      if(data.sftgcs == 0){
        $scope.bjMsg = "企业基本信息没有通过初审不能评级";
        return;
      }
      //无实体集团的，不能评级
      if(data.qylxxx == 2){
        $scope.bjMsg = "无实体集团不能评级";
        return;
      }
      //企业级别为空
      if(data.qyjb == null){
        $scope.bjMsg = "暂时没有评级";
        return;
      }
      //其他的
      $scope.bjMsg = data.qyjb;
    });
  });
